home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ams__l~1.zoo / src / mousepos.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-25  |  1.3 KB  |  68 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is part of the Atari Machine Specific Library,
  4. //  and is Copyright 1992 by Warwick W. Allison.
  5. //
  6. //  You are free to copy and modify these sources, provided you acknowledge
  7. //  the origin by retaining this notice, and adhere to the conditions
  8. //  described in the file COPYING.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #include "MousePosition.h"
  13. #include <osbind.h>
  14.  
  15. MousePosition Mouse;
  16.  
  17. void MousePosition::Bind()
  18. {
  19.     if (x<minx) x=minx;
  20.     else if (x>maxx) x=maxx;
  21.     if (y<miny) y=miny;
  22.     else if (y>maxy) y=maxy;
  23. }
  24.  
  25. struct Packet
  26. {
  27.     short Header:8;
  28.     short x:8;
  29.     short y:8;
  30. };
  31.  
  32. void MyInt(Packet* Data)
  33. {
  34.     Mouse.SetLeft(!!(Data->Header&2));
  35.     Mouse.SetRight(!!(Data->Header&1));
  36.     Mouse.MoveBy(Data->x,Data->y);
  37. }
  38.  
  39. MousePosition::MousePosition() :
  40.     x(0),
  41.     y(0),
  42.     Left(FALSE),
  43.     Right(FALSE),
  44.     Bounded(FALSE)
  45. {
  46.     struct _KBDVECS *Base=Kbdvbase();
  47.  
  48.     Ikbdws(1,"\010");
  49.     OldVec=(void*)Base->mousevec;
  50.     Base->mousevec=(void(*)(void*))MyInt;
  51. }
  52.  
  53. void MousePosition::Speed(short x, short y)
  54. {
  55.     char *T="\013??";
  56.     T[1]=x;
  57.     T[2]=y;
  58.     Ikbdws(3,T);
  59. }
  60.  
  61. MousePosition::~MousePosition()
  62. {
  63.     struct _KBDVECS *Base=Kbdvbase();
  64.  
  65.     Base->mousevec=(void(*)(void*))OldVec;
  66.     Ikbdws(3,"\013\01\01");
  67. }
  68.